package com.yyx.app1.tool;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

/**
 * Created by yuexing on 2015/11/9.
 */
public class MySharedPreferences {

    public static void put(Context context,String key,String value)
    {
        SharedPreferences sp= context.getSharedPreferences("myApp", Context.MODE_PRIVATE); //私有数据
        SharedPreferences.Editor editor = sp.edit();//获取编辑器
        editor.putString(key, value);
        editor.commit();//提交修改
    }

    public static String get(Context context,String key)
    {
        SharedPreferences sp= context.getSharedPreferences("myApp", Context.MODE_PRIVATE); //私有数据
        return sp.getString(key, null);
    }

    public static void findAll(Context context)
    {
        SharedPreferences sp= context.getSharedPreferences("myApp", Context.MODE_PRIVATE); //私有数据
        Log.i("正常",sp.getAll().toString());
    }

    public static void clear(Context context)
    {
        SharedPreferences sp= context.getSharedPreferences("myApp", Context.MODE_PRIVATE); //私有数据
        SharedPreferences.Editor editor = sp.edit();//获取编辑器
        editor.clear();
        editor.commit();//提交修改
    }
}
